package api

import (
	"github.com/gin-gonic/gin"
	jwt2 "github.com/golangblogs/gojwt"
	"good/api/handler"
	"good/consts"
)

func LoadRoutes(r *gin.Engine) {
	api := r.Group("/api")
	{
		user := api.Group("/user") //todo: 用户模块
		{
			user.POST("/createUser", handler.CreateUser) //注册
			user.POST("/loginUser", handler.LoginUser)   //登录
		}
		chat := api.Group("/chat") // todo: websocket通信
		{
			chat.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			chat.GET("/chat", handler.Chat)                  //websocket
			chat.POST("/queryComment", handler.QueryComment) // 查询历史聊天记录
		}
		admin := api.Group("/admin") // todo: 管理员群发接口
		{
			admin.Use(jwt2.JWTAuth(consts.JWT_SELECT_KEY))
			admin.POST("/allAdmin", handler.AllAdmin) //群发接口
		}
	}
}
